<template>
  <!-- 列表 -->
  <ContentWrap>
    <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
      <el-table-column label="税费序号" align="center" prop="id">
        <template #default="scope">
          <el-link type="primary" @click="openTaxationForm('update', scope.row.id)">{{
            scope.row.id
          }}</el-link>
        </template>
      </el-table-column>
      <el-table-column label="纳税人识别号" align="center" prop="taxationTaxid" />
      <el-table-column label="实缴(退)金额(元)" align="center" prop="taxationAmount" />
      <el-table-column label="税种" align="center" prop="taxationType" />
      <el-table-column label="品目名称" align="center" prop="taxationName" />
      <el-table-column label="税务机关" align="center" prop="taxationAuthority" />
      <el-table-column
        label="税款所属开始日期"
        align="center"
        prop="taxationBegintime"
        :formatter="dateFormatter"
        width="180px"
      />
      <el-table-column
        label="税款所属结束日期"
        align="center"
        prop="taxationEndtime"
        :formatter="dateFormatter"
        width="180px"
      />
      <el-table-column
        label="入(退)库日期"
        align="center"
        prop="taxationTime"
        :formatter="dateFormatter"
        width="180px"
      />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="状态" align="center" prop="status">
        <template #default="scope">
          <dict-tag :type="DICT_TYPE.SYS_STATUS" :value="scope.row.status" />
        </template>
      </el-table-column>
    </el-table>
  </ContentWrap>
  <TaxationForm ref="taxationFormRef" @success="getList" />

</template>
<script setup lang="ts">
import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import { RentApi } from '@/api/zszx/rent'
import TaxationForm from '@/views/zszx/taxation/TaxationForm.vue'

const taxationFormRef = ref()
const openTaxationForm = (type: string, id?: number) => {
  taxationFormRef.value.open(type, id)
}

const { t } = useI18n() // 国际化
const message = useMessage() // 消息弹窗

const props = defineProps<{
  rentId?: number // 合同序号（主表的关联字段）
}>()
const loading = ref(false) // 列表的加载中
const list = ref([]) // 列表的数据

/** 查询列表 */
const getList = async () => {
  loading.value = true
  try {
    list.value = await RentApi.getTaxationListByRentId(props.rentId)
  } finally {
    loading.value = false
  }
}

/** 搜索按钮操作 */
const handleQuery = () => {
  queryParams.pageNo = 1
  getList()
}

/** 初始化 **/
onMounted(() => {
  getList()
})
</script>
